package com.robot.orders.dao;

import com.robot.orders.pojo.Settlement;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

/**
 * settlement数据访问接口
 *
 * @author wuyunbin
 */
public interface SettlementDao extends JpaRepository<Settlement, String>, JpaSpecificationExecutor<Settlement> {
    /**
     * 更改settlement表的status状态0-未提现 1-已提现
     *
     * @param status
     * @param now
     * @param agentId
     * @param settlementDate
     */
    @Modifying
    @Transactional(rollbackFor = Exception.class)
    @Query(value = "update orders.settlement set status=?,orders.settlement.updated_at=? where agent_id=? and settlement_date=?", nativeQuery = true)
    public void updateSettlementStatus(String status, LocalDateTime now, String agentId, String settlementDate);
}
